package com.tidemark;

/**
 * Stock, contains stock-code and stock-name
 * stock is sortable by stock-code 
 *
 */
public class Stock implements Comparable<Stock>{
	private String m_code;
	private String m_name;
	//TODO private String pinyin;  e.g.//ZGLT for 中国联通
	private String m_comments;
	private boolean buy = false; //suggestion, default not to buy
	
	public boolean isBuy() {
		return buy;
	}

	public void setBuy(boolean buy) {
		this.buy = buy;
	}

	public String getComments() {
		return m_comments;
	}

	public void setComments(String comments) {
		this.m_comments = comments;
	}

	public Stock() {
		this("-1", "");
	}
	
	public Stock(String code, String name) {
		m_code = code;
		m_name = name;
	}
	
	public Stock(String code, String name, String comments) {
		m_code = code;
		m_name = name;
		m_comments = comments;
	}
	
	@Override
	public int compareTo(Stock arg0) {
		int code0 = Integer.parseInt(arg0.getCode());
		int code1 = Integer.parseInt(this.getCode());
		
			if(code0 == code1){
				return 0;
			}else	if(code1 < code0){
				return -1;
			}else{
				return 1;
			}
	}

	public String getCode() {
		return m_code;
	}

	public void setCode(String code) {
		this.m_code = code;
	}

	public String getName() {
		return m_name;
	}

	public void setName(String name) {
		this.m_name = name;
	}
	
	public String toString() {
		return m_code + " " + m_name;
	}
}